/*
 * @Author: ZhaoZhiqi
 * @Date: 2024-04-28 15:10:57
 * @LastEditors: ZhaoZhiqi
 * @LastEditTime: 2025-01-03 18:06:07
 * @Description: API
 * @FilePath: \charging-mini\充电项目\src\api\api.js
 */
import http from "./http";

/**
 * @description: 登录
 * @param {String} code wx.login()回调code
 * @return {*}
 */
export const loginAPI = (data) =>
    http({
        url: `charging-mini/api/mini/login`,
        method: "POST",
        data,
    });

/**
 * @description: 手机号认证
 * @param {String} code
 * @return {*}
 */
export const bindPhoneAPI = (data) =>
    http({
        url: `charging-mini/api/mini/auth/user/phone_auth`,
        method: "POST",
        data,
    });

/**
 * @description: 查询订单列表
 * @param {String} orderCate 订单类型 ALL:全部 CHARGING：待结算 FINISH：已完成 ABNORMAL：异常订单
 * @param {Number} page 页码
 * @return {*}
 */
export const getOrderListAPI = (data) =>
    http({
        url: `charging-mini/api/mini/auth/order/list`,
        method: "GET",
        data,
    });

/**
 * @description: 查询订单详情
 * @param {String} orderNo 订单号
 * @return {*}
 */
export const getOrderDetailAPI = (data) =>
    http({
        url: `charging-mini/api/mini/auth/order/detail`,
        method: "GET",
        data,
    });

/**
 * @description: 停止充电
 * @param {String} orderNo 订单号
 * @return {*}
 */
export const terminateChargeAPI = (data) =>
    http({
        url: `charging-mini/api/mini/auth/order/terminate`,
        method: "GET",
        data,
    });

/**
 * @description: 获取充电桩设备信息
 * @param {String} code
 * @return {*}
 */
export const getStationDetailAPI = (data) =>
    http({
        url: `charging-mini/api/mini/auth/station`,
        method: "GET",
        data,
    });

/**
 * @description: 创建充电订单
 * @param {Number} amount
 * @param {String} pay_type
 * @param {String | Number} port
 * @param {String} station_serial_num
 * @return {*}
 */
export const createOrderAPI = (data) =>
    http({
        url: `charging-mini/api/mini/auth/order/charge`,
        method: "POST",
        data,
    });

/**
 * @description: 查询支付结果
 * @param {Number | String} orderNo
 * @return {*}
 */
export const checkOrderResultAPI = (data) =>
    http({
        url: `charging-mini/api/mini/auth/order/pay/result`,
        method: "GET",
        data,
    });

/**
 * @description: 提交反馈
 * @param {String} charge_record_id 充电记录id
 * @param {String} feedback_type 反馈类型
 * @param {String} imgs 反馈图片
 * @param {String} reason_desc 反馈内容
 * @param {String} station_serial_num 站点序列号
 * @return {*}
 */
export const submitFeedbackAPI = (data) =>
    http({
        url: `charging-mini/api/mini/auth/feedback/submit`,
        method: "POST",
        data,
    });

/**
 * @description: 获取卡列表
 * @param {String} card_no
 * @return {*}
 */
export const getCardsListAPI = (data) =>
    http({
        url: `charging-mini/api/mini/auth/wallet/card/list`,
        method: "GET",
        data,
    });

/**
 * @description: 绑定卡
 * @param {String} card_no
 * @return {*}
 */
export const bindCardAPI = (data) =>
    http({
        url: `charging-mini/api/mini/auth/wallet/card/bind`,
        method: "POST",
        data,
    });

/**
 * @description: 查询钱包余额
 * @return {*}
 */
export const getBalanceAPI = () =>
    http({
        url: `charging-mini/api/mini/auth/wallet`,
        method: "GET",
    });

/**
 * @description: 充值商品列表
 * @return {*}
 */
export const getRechargeItemsAPI = () =>
    http({
        url: `charging-mini/api/mini/auth/recharge/products`,
        method: "GET",
    });

/**
 * @description: 创建充值订单
 * @return {*}
 */
export const rechargeAPI = (data) =>
    http({
        url: `charging-mini/api/mini/auth/order/recharge`,
        method: "POST",
        data,
    });

/**
 * @description: 计算充值充电价格
 * @return {*}
 */
export const getRealPriceAPI = (data) =>
    http({
        url: `/charging-mini/api/mini/auth/order/charge/price`,
        method: "GET",
        data,
    });

/**
 * @description: 查询消费列表
 * @param {String} cardNo 卡号
 * @param {Number} page 页码
 * @return {*}
 */
export const getCardConsumeListAPI = (data) =>
    http({
        url: `charging-mini/api/mini/auth/order/card/consume/list`,
        method: "GET",
        data,
    });

/**
 * @description: 查询充值列表
 * @param {String} cardNo 卡号
 * @param {Number} page 页码
 * @return {*}
 */
export const getCardRechargeListAPI = (data) =>
    http({
        url: `charging-mini/api/mini/auth/order/card/recharge/list`,
        method: "GET",
        data,
    });

/**
 * @description: 计算开票金额
 * @param {Array<String>} orderNos 订单号数组
 * @return {*}
 */
export const getInvoiceAmountAPI = (data) =>
    http({
        url: `charging-mini/api/mini/auth/invoice/cal/amount`,
        method: "POST",
        data,
    });

/**
 * @description: 查询可开票列表
 * @param {Number} page 页码
 * @return {*}
 */
export const getNotInvoicedListAPI = (data) =>
    http({
        url: `/charging-mini/api/mini/auth/invoice/can/list`,
        method: "GET",
        data,
    });

/**
 * @description: 查询已开票列表
 * @param {Number} page 页码
 * @return {*}
 */
export const getInvoiceListAPI = (data) =>
    http({
        url: `charging-mini/api/mini/auth/invoice/his`,
        method: "GET",
        data,
    });

/**
 * @description: 提交开票
 * @return {*}
 */
export const submitInvoiceAPI = (data) =>
    http({
        url: `charging-mini/api/mini/auth/invoice/submit`,
        method: "POST",
        data,
    });

/**
 * @description: 获取站点列表
 * @return {*}
 */
export const getSiteListAPI = (data = {}) =>
    http({
        url: `charging-mini/api/mini/site/list`,
        method: "GET",
        data,
    });

/**
 * @description: 获取充电桩列表
 * @return {*}
 */
export const getStationListAPI = (data = {}) =>
    http({
        url: `charging-mini/api/mini/site/station/list`,
        method: "GET",
        data,
    });
